local chuangying = fk.CreateSkill {
  name = "lingling__chuangying",
  tags = { Skill.Compulsory, Skill.Switch }
}

Fk:loadTranslationTable {
  ["lingling__chuangying"] = "闯营",
  [":lingling__chuangying"] = "锁定技，转换技，①防止你受到的伤害；②你造成的伤害+1。当你使用【杀】被抵消后，转换此技能。",
  [":lingling__chuangying_yang"] = "锁定技，转换技，<font color=\"#E0DB2F\">①防止你受到的伤害；</font>②你造成的伤害+1。当你使用【杀】被抵消后，转换此技能。",
  [":lingling__chuangying_yin"] = "锁定技，转换技，①防止你受到的伤害；<font color=\"#E0DB2F\">②你造成的伤害+1。</font>当你使用【杀】被抵消后，转换此技能。",
}

local U = require "packages/utility/utility"

chuangying:addEffect(fk.DamageInflicted, {
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(chuangying.name) and target == player and
        player:getSwitchSkillState(chuangying.name) == fk.SwitchYang
  end,
  on_use = function(self, event, target, player, data)
    data:preventDamage()
  end
})

chuangying:addEffect(fk.DamageCaused, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(chuangying.name) and target == player and
        player:getSwitchSkillState(chuangying.name) == fk.SwitchYin
  end,
  -- on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    data:changeDamage(1)
  end
})

chuangying:addEffect(fk.CardEffectCancelledOut, {
  anim_type = "switch",
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(chuangying.name) and data.card.trueName == "slash"
  end,
  on_use = function(self, event, target, player, data)
    U.SetSwitchSkillState(player, chuangying.name)
  end,
})

return chuangying
